package com.frinder.akka;

import akka.actor.Extension;
import akka.actor.Props;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * Created by frinder on 2017/7/25.
 */
@Component
public class SpringExtension implements Extension {

    private final Logger logger = LoggerFactory.getLogger(getClass());

    private ApplicationContext applicationContext;

    public void initialize(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }

    public Props props(String actorBeanName, Object... args) {
        logger.debug("Create Actor : {}", actorBeanName);
        return Props.create(SpringActorProducer.class, applicationContext, actorBeanName, args);
    }

}
